Conversation
alecthomas
left a comment
There was a problem hiding this comment.
This is awesome. Looking at the code, as discussed I do think at some point we can probably consolidate these into a more flexible generalised strategy, but let's wait for some more patterns to emerge before we do.
internal/strategy/artifactory.go
Outdated
|
|
||
| if isHostBased { | ||
| // Host-based: use full request path as-is | ||
| // Request: GET http://maven.block-artifacts.com/libs-release/foo.jar |
There was a problem hiding this comment.
We should probably rename these to something non-Block specific (example.com)
There was a problem hiding this comment.
Bleh, thought I scrubbed all those out. Fixed now.
I'm having CII review this further, there may be further optimizations and considerations for Artifactory that I haven't implemented yet... but this at a minimum is functional :). Hopefully the code can be consolidated though. |
What?
Implements a strategy for caching packages stored in Artifactory. This caching strategy supports both path based and host based URL's.
Why?
Artifactory is a commonly used package store that requires first class support.
Tests
Implemented unit testing. Additionally the following manual testing has been performed with various Build tools.
Added a test configuration...
Add an entry to
/etc/hosts...NPM
Result from second-run post-caching:
Gems
time gem install rack --clear-sources --source http://gems.local:8080/ --install-dir ./vendor --no-document --version 2.2.3 Fetching rack-2.2.3.gem Successfully installed rack-2.2.3 1 gem installed real 0m25.421s user 0m14.404s sys 0m0.229sPyPi
Maven
Add a settings.xml...
mvn dependtiee mncy:get -s settings.xml -DgroupId=commons-lang -DartifactId=commons-lang -Dversion=2.6 -Dtransitive=false [INFO] Scanning for projects... Downloading from cachew-proxy: http://test.local:8080/artifactory/common/org/codehaus/mojo/maven-metadata.xml Downloading from cachew-proxy: http://test.local:8080/artifactory/common/org/apache/maven/plugins/maven-metadata.xml Downloaded from cachew-proxy: http://test.local:8080/artifactory/common/org/codehaus/mojo/maven-metadata.xml (21 kB at 4.1 kB/s) Downloaded from cachew-proxy: http://test.local:8080/artifactory/common/org/apache/maven/plugins/maven-metadata.xml (10 kB at 2.1 kB/s) Downloading from cachew-proxy: http://test.local:8080/artifactory/common/org/apache/maven/plugins/maven-dependency-plugin/3.7.0/maven-dependency-plugin-3.7.0.pom Downloaded from cachew-proxy: http://test.local:8080/artifactory/common/org/apache/maven/plugins/maven-dependency-plugin/3.7.0/maven-dependency-plugin-3.7.0.pom (19 kB at 3.7 MB/s) ... SNIP ... Downloaded from cachew-proxy: http://test.local:8080/artifactory/common/commons-lang/commons-lang/2.6/commons-lang-2.6.jar (284 kB at 271 kB/s) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.070 s [INFO] Finished at: 2026-01-16T13:31:31+11:00 [INFO] ------------------------------------------------------------------------ real 0m7.828s user 0m3.924s sys 0m0.790s